package com.jml.单例模式;

public class 静态匿名内部类 {

    public String a="a";

    private 静态匿名内部类() {
        //私有构造方法
        System.out.println("初始化..");
    }
    private static class SingletonClassInstance {

        private static final 静态匿名内部类 inerStaticSingle = new 静态匿名内部类();
    }
    // 方法没有同步
    public static 静态匿名内部类 getInstance() {
        System.out.println("getInstance");
        return SingletonClassInstance.inerStaticSingle;
    }


    public static void main(String[] args) {
        静态匿名内部类 s1 = 静态匿名内部类.getInstance();
        s1.a="22";
        静态匿名内部类 s2 = 静态匿名内部类.getInstance();
        System.out.println(s1);
        System.out.println(s2);
        System.out.println(s1 == s2);
    }
}
